package com.study.example.gameserver.module.buff.domain;

import com.sparrow.common.util.JsonUtil;
import com.sparrow.common.util.StringUtil;
import com.sparrow.common.buff.domain.IBuffEffectParam;
import com.study.example.gameserver.module.buff.effect.param.SimpleBuffEffectParam;

/**
 * Buff效果类型 每种效果的参数需要在自己解析
 */
public enum BuffEffectType {
    AddAttack(SimpleBuffEffectParam.class),
    DoubleExp(SimpleBuffEffectParam.class);

    private final Class<? extends IBuffEffectParam> paramClazz;

    BuffEffectType(Class<? extends IBuffEffectParam> paramClazz) {
        this.paramClazz = paramClazz;
    }

    public IBuffEffectParam parse(String effectParam) {
        if (StringUtil.isEmpty(effectParam)) {
            return null;
        }
        return JsonUtil.parse(effectParam, this.paramClazz);
    }
}
